<link rel="stylesheet" type="text/css" href="{$smarty.const.BASE_URL}/modules/rsrequestmodule/css/rsrequestmodule.css" />
<script language="javascript" src="{$smarty.const.BASE_URL}/modules/rsrequestmodule/js/rsrequestmodule.js"></script>
<div class="rsrequestmodule">
    <h1>Quản lý các yêu cầu bất động sản</h1>
    <ul class="rsrequest_manage">
        {foreach from=$requests item=request }
        <li class="request_item">
            {permissions level=$smarty.const.UILEVEL_PERMISSIONS}
            <div class="itemactions">
                {if $permissions.edit == true || $permissions.administrate == true}
                    <a class="rsrequest_pencil" id="r{$request->id}" href="javascript:void(0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
                {/if}
                {if $permissions.delete == true || $permissions.administrate == true}
                    <a onclick="return confirm('Bạn thực sự muốn xóa?');" href="{link action=delete id=$request->id}"><img src="{$smarty.const.ICON_RELATIVE}delete.png" title="{$_TR.alt_delete}" alt="{$_TR.alt_delete}" ></a>
                {/if}
            </div>
            {/permissions}
            <div class="request_index">
                {$start_index}.
                {assign var=start_index value=$start_index+1}
                <div class="request_item_header">
                    {$request->request_date}
                    {if $admin_mode == 1 }
                    {if $request->userfullname != null}
                    &nbsp;- <span>{$request->userfullname}</span>
                    {/if}
                    {if $request->username != null}
                    &nbsp;(<span>{$request->username}</span>)
                    {/if}
                    {/if}
                </div>
            </div>
            <ul class="request_item_userinfo">
                <li>
                    <span>Tên người liên hệ</span>: {$request->fullname}
                </li>
                <li>
                    <span>Điện thoại</span>: {$request->phone}
                </li>
                <li>
                    <span>Email</span>: {$request->email}
                </li>
            </ul>
            <div class="body_wrapper">
                <div class="request_item_body">
                    {$request->content}
                </div>
            </div>
            
            <div class="rsrequest_respone_form" id="respone_form{$request->id}"></div>
            {if count($request->respones) > 0}
                <div class="respone_header">
                    <div class="title">Phản hồi từ Nhà Đất Tự Do</div>
                {foreach from=$request->respones item=respone name=responef}
                    <div class="respone">
                    {permissions level=$smarty.const.UILEVEL_PERMISSIONS}
                    <div class="itemactions">
                        {if $permissions.delete == true || $permissions.administrate == true}
                        <a onclick="return confirm('Bạn thực sự muốn xóa?');" href="{link action=delete id=$respone->id}"><img src="{$smarty.const.ICON_RELATIVE}delete.png" title="{$_TR.alt_delete}" alt="{$_TR.alt_delete}" ></a>
                        {/if}
                    </div>
                    {/permissions}
                    <div class="request_index">
                    {$smarty.foreach.responef.index+1}.
                            <div class="request_item_header">
                        {$respone->request_date}
                            {if $respone->userfullname != null}
                        &nbsp;- <span>{$respone->userfullname}</span>
                            {/if}
                            {if $respone->username != null}
                        &nbsp;(<span>{$respone->username}</span>)
                            {/if}
                            </div>
                        </div>
                        <div class="respone_body">
                            {$respone->content}
                        </div>
                    </div>
                {/foreach}
                </div>
            {/if}
        </li>
        {foreachelse}
        <li class="request_empty form_header">
            <p>{$_TR.request_empty}</p>
        </li>
        {/foreach}
    </ul>

    {paging current_page=$page pages=$pages action='manage' module=rsrequestmodule src=$__loc->src}
</div>